﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Elderos.Ontology;

namespace Elderos.Highlight.Rules
{
    [RankingRule("WordsDict", RuleType.Synonym)]
    public class RuleWordsDict : SynonymRule
    {
        public RuleWordsDict(IOntologyData ontology) : base(ontology)
        {}

        private readonly string[] _factorNames =
        {
            "WordsDict_TextFrequency",
            "WordsDict_WordFrequency"
        };

        public override IRuleResult EmptyResult
        {
            get { return new ArrayResult(_factorNames, new double[]{0, 0});}
        }

        protected override IRuleResult ComputeResult(string synonym)
        {
            string syno = synonym.ToLower();
            if (!Ontology.WordsDictionary.ContainsKey(syno))
                return EmptyResult;
            DictionaryWord word = Ontology.WordsDictionary[syno];
            return new ArrayResult(_factorNames, new double[]{word.TextFrequency, word.WordFrequency});
        }
    }
}
